<?php echo Modules::run('common/header') ?>

<script src="<?php echo base_url();?>assets/js/ckeditor.js"></script>

	<!-- Begin page content -->
	<div class="container content-body">
		<div class="page-header">
  			<h1>My Store</h1>
		</div>

		<div id="message"></div>

			<?php
				$nama_toko = array(
					'name'	=> 'nama_toko',
					'id'	=> 'nama_toko',
					'value' => set_value('nama_toko', $nama_toko),
					'class' => 'input-xlarge',
					'disabled'=> 'disabled',
				);

				$judul_toko = array(
					'name'	=> 'judul_toko',
					'id'	=> 'judul_toko',
					'value' => set_value('judul_toko', $judul_toko),
					'class' => 'input-xlarge',
				);

				$description = array(
					'name'	=> 'description',
					'id'	=> 'description',
					'value' => set_value('description', $description),
					'class' => 'ckeditor input-xlarge',
				);

				$alamat = array(
					'name'	=> 'alamat',
					'id'	=> 'alamat',
					'value' => set_value('alamat', $alamat),
					'class' => 'input-xlarge',
					'maxlength'=> '255'
				);

				$telepon = array(
					'name'	=> 'telepon',
					'id'	=> 'telepon',
					'value' => set_value('telepon', $telepon),
					'class' => 'input-xlarge',
				);

				$hp = array(
					'name'	=> 'hp',
					'id'	=> 'hp',
					'value' => set_value('hp', $hp),
					'class' => 'input-xlarge',
				);

				$kode_pos = array(
					'name'	=> 'kode_pos',
					'id'	=> 'kode_pos',
					'value' => set_value('kode_pos', $kode_pos),
					'class' => 'input-xlarge',
				);

				$kota = array(
					'name'	=> 'kota',
					'id'	=> 'kota',
					'value' => set_value('kota', $kota),
					'class' => 'input-xlarge',
				);

				$provinsi = array(
					'name'	=> 'provinsi',
					'id'	=> 'provinsi',
					'value' => set_value('provinsi', $provinsi),
					'class' => 'input-xlarge',
				);

				$negara = array(
					'name'	=> 'negara',
					'id'	=> 'negara',
					'value' => set_value('negara', $negara),
					'class' => 'input-xlarge',
				);
			?>

		<?php echo form_open_multipart($this->uri->uri_string(),'id="" class="form-horizontal"'); ?>

			<div class="control-group">
              	<label class="control-label" for="nama_toko">Store Name <span style="color: red;">*</span></label>
              <div class="controls">
                <?php echo form_input($nama_toko); ?> <?php echo form_error($nama_toko['name']); ?>
              </div>
            </div>
	    	<hr>

	    	<div class="control-group">
              	<label class="control-label" for="logo">Logo </label>
              <div class="controls">              	

              	<div id="logo_image" style="display:<?php echo $logo != '' ? 'block': 'none'; ?>">                
                <input type="hidden" name="logo_file" value="<?php echo $logo; ?>">
                <img src="<?php echo base_url('data/thumb/'.$logo)?>" class="img-polaroid">
                <a class="btn" style="cursor:pointer;" onclick="clear_logo();" title="Clear Logo"><i class="icon-trash"></i> Hapus</a>
        
            	</div>

	            <div id="logo_input" style="display:<?php echo $logo == '' ? 'block': 'none'; ?>">
	            <input type="file" name="logo" title="Browse File">
	            <input type="hidden" name="del_i" value="0">
	            </div>

              </div>
            </div>
	    	<hr>

	    	<div class="control-group">
              	<label class="control-label" for="judul_toko">Store Title <span style="color: red;">*</span></label>
              <div class="controls">
                <?php echo form_input($judul_toko); ?> <?php echo form_error($judul_toko['name']); ?>
              </div>
            </div>
	    	<hr>

	    	<div class="control-group">
              	<label class="control-label" for="description">Description <span style="color: red;">*</span></label>
              <div class="controls">
              	<div style="width:700px;">
                <?php echo form_textarea($description); ?> <?php echo form_error($description['name']); ?>
            	</div>
              </div>
            </div>
	    	<hr>

	    	<div class="control-group">
              	<label class="control-label" for="alamat">Address <span style="color: red;">*</span></label>
              <div class="controls">       
              	<div style="width:400px;">       	
                <?php echo form_textarea($alamat); ?> <?php echo form_error($alamat['name']); ?>  
                </div>          	
              </div>
            </div>
	    	<hr>

	    	<div class="control-group">
              	<label class="control-label" for="telepon">Telephone <span style="color: red;">*</span></label>
              <div class="controls">
                <?php echo form_input($telepon); ?> <?php echo form_error($telepon['name']); ?>
              </div>
            </div>
	    	<hr>

	    	<div class="control-group">
              	<label class="control-label" for="hp">Handphone <span style="color: red;">*</span></label>
              <div class="controls">
                <?php echo form_input($hp); ?> <?php echo form_error($hp['name']); ?>
              </div>
            </div>
	    	<hr>

	    	<div class="control-group">
              	<label class="control-label" for="kota">City <span style="color: red;">*</span></label>
              <div class="controls">
                <?php echo form_input($kota); ?> <?php echo form_error($kota['name']); ?>
              </div>
            </div>
	    	<hr>

	    	<div class="control-group">
              	<label class="control-label" for="kode_pos">Post Code <span style="color: red;">*</span></label>
              <div class="controls">
                <?php echo form_input($kode_pos); ?> <?php echo form_error($kode_pos['name']); ?>
              </div>
            </div>
	    	<hr>

	    	<div class="control-group">
              	<label class="control-label" for="negara">Country: <span style="color: red;">*</span></label>
              <div class="controls">
                <?php //echo form_input($negara); ?> <?php echo form_error($negara['name']); ?>
                <select name="negara" id="negara" style="width: 285px;">
                	<?php foreach ($list_country as $key => $val) { ?>
                	<option value="<?php echo $val->name; ?>" <?php echo $val->name == $curent_country ? "selected='selected'":"" ?>> <?php echo $val->name ?></option>
                	<?php } ?>	              					
                </select>
              </div>
            </div>
	    	<hr>

	    	<div class="control-group">
              	<label class="control-label" for="provinsi">Region / State <span style="color: red;">*</span></label>
              <div class="controls">
                <?php //echo form_input($provinsi); ?> <?php echo form_error($provinsi['name']); ?>
                <select name="provinsi" id="provinsi" style="width: 285px;">
                	<option value="">-- Select --</option>
                	<?php foreach ($list_region as $key => $val) { ?>
                	<option value="<?php echo $val->name; ?>" <?php echo $val->name == $curent_region ? "selected='selected'":"" ?>> <?php echo $val->name ?></option>
                	<?php } ?>	              					
                </select>
              </div>
            </div>
	    	<hr>

            <button type="submit" class="btn btn-primary">Submit</button> 

          <?php echo form_close(); ?>

	</div>
<script type="text/javascript">
CKEDITOR.replace( 'alamat', {
	toolbar: []
});

function clear_logo(){
	$("#logo_image").hide();
	$("#logo_input").show();
	$("input[name=del_i]").val('1');
	
}

$(document).ready(function() {
	$("#negara").change(function() {
		var countryId = $(this).val();
		//console.log(countryId);
		var url = window.site_url + 'manager/get_region/'+countryId;
		$('#provinsi').empty();

		$.post(url, function(data) {
			if(data == ''){
				
				$('#provinsi').append('<option> None </option>');
			}
			else{
				
				$('#provinsi').append(data);
			}
		});		
	});
});


</script>
<?php echo Modules::run('common/footer') ?>